{include file="public/header" /}
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.fuwu_personal}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
        <form id="form" method="post" name="form1">
            <input type="hidden" name="id" value="{$data.id}" id="id"/>
            <table class="ds-default-table">
                <tbody>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_name}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$data.name}" name="name" id="name" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_idcard}:</label></td>
                    <td class="vatop rowform"><input type="text" value="{$data.idcard}" name="idcard" id="idcard" class="txt"></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_cardimgz}:</label></td>
                    <td class="vatop rowform">
                        <img src="{$data.cardImgZ}" width="150"/>
                        <input  name="file" id='upload_img1'  type="file">
                        <input type="hidden" name="cardImgZ" id='cardImgZ' value="{$data.cardImgZ}" >
                    </td>
                    <td class="vatop tips">请上传后缀名为：*.jpeg *.jpg *.png 的文件</td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_cardimgf}:</label></td>
                    <td class="vatop rowform">
                        <img src="{$data.cardImgF}" width="150"/>
                        <input  name="file" id='upload_img2'  type="file">
                        <input type="hidden" name="cardImgF" id='cardImgF' value="{$data.cardImgF}" >
                    </td>
                    <td class="vatop tips">请上传后缀名为：*.jpeg *.jpg *.png 的文件</td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_cardImgs}:</label></td>
                    <td class="vatop rowform">
                        <img src="{$data.cardImgS}" width="150"/>
                        <input  name="file" id='upload_img3'  type="file">
                        <input type="hidden" name="cardImgS" id='cardImgS' value="{$data.cardImgS}" >
                    </td>
                    <td class="vatop tips">请上传后缀名为：*.jpeg *.jpg *.png 的文件</td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_learning}:</label></td>
                    <td class="vatop rowform"><textarea type="text" value="" name="learning" id="learning">{$data.learning}</textarea></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w120"><label class="validation">{$Think.lang.fuwu_personal_work}:</label></td>
                    <td class="vatop rowform"><textarea type="text" value="" name="work" id="work" class="txt">{$data.work}</textarea></td>
                    <td class="vatop tips"></td>
                </tr>
                <tr class="noborder">
                    <td class="required w120">{$Think.lang.fuwu_personal_cardstatus}:</td>
                    <td class="vatop rowform">
                        <input type="radio" value="1" name="cardstatus" id="cardstatus" checked>认证成功
                    </td>
                    <td class="vatop tips"></td>
                </tr>
                <!--<tr class="noborder">-->
                    <!--<td class="required w120">{$Think.lang.fuwu_personal_cardfail_resonse}:</td>-->
                    <!--<td class="vatop rowform"><textarea type="text" value="{$data.cardfail_resonse}" name="cardfail_resonse" id="cardfail_resonse" class="txt"></textarea></td>-->
                    <!--<td class="vatop tips"></td>-->
                <!--</tr>-->


                </tbody>
                <tfoot>
                <tr class="tfoot">
                    <td colspan="15" ><input class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
                </tr>
                </tfoot>
            </table>
        </form>
    </div>
<script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
<link rel="stylesheet" href="{$Think.CHAT_SITE_URL}/css/chat.css">
<script>
//按钮先执行验证再提交表
    $(document).ready(function () {
        $("#form").validate({
        errorPlacement: function (error,element) {
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules:{
                name:{
                    required:true,
                    checkname:true
                },
                idcard:{
                    required:true,
                    remote:{
                        url:ADMINSITEURL+'/Zhuwork/ajax_idcard.html',
                        type:'get',
                        data:{
                            idcard:function () {
                                return $('#idcard').val();
                            },
                        }
                    }
                },
                learning:{
                    required:true
                },
                work:{
                    required:true
                },

            },
            messages:{
                name:{
                    required:'{$Think.lang.fuwu_personal_name_bi}',
                    checkname:'{$Think.lang.fuwu_personal_name_min}'
                },
                idcard:{
                    required:'{$Think.lang.fuwu_personal_idcard_bi}',
                    remote:'{$Think.lang.fuwu_personal_idcard_reg}'
                },
                learning:{
                    required:'{$Think.lang.fuwu_personal_learning_bi}',
                },
                work:{
                    required:'{$Think.lang.fuwu_personal_work_bi}',
                }
            }
        });
        //自定义正则表达示验证方法
        $.validator.addMethod("checkphone",function(value,element,params){
            var checkQQ = /^[1][3,4,5,7,8,9][0-9]{9}$/;
            return this.optional(element)||(checkQQ.test(value));
        },"{$Think.lang.fuwu_personal_phone_geshi}");
        $.validator.addMethod("checkname",function(value,element,params){
            var checkname = /^[\u4e00-\u9fa5]{2,5}$/;
            return this.optional(element)||(checkname.test(value));
        },"{$Think.lang.fuwu_personal_name_min}");
    });
$(document).on('change','#upload_img1',function() {
    var files = document.getElementById('upload_img1').files[0];
    var formData = new FormData();
    formData.append('file',files);
    layer.msg('正在上传，请稍后');
    $.ajax({
        //请求方式
        type : "POST",
        //请求地址
        url : "ajax_upload",
        data : formData,
        cache:false,  //默认是true，但是一般不做缓存
        processData:false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
        contentType:false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
        //请求成功
        success : function(result) {
            if(result.err==0){
                layer.msg(result.msg);
                $('#cardImgZ').val(result.data);
            }else{
                $('#cardImgZ').val('');
                alert('文件信息错误,请重新上传');return false;
            }



        },
        //请求失败，包含具体的错误信息
        error : function(e){
            console.log(e.status);
            console.log(e.responseText);
        }
    });

});
$(document).on('change','#upload_img2',function() {
    var files = document.getElementById('upload_img2').files[0];
    var formData = new FormData();
    formData.append('file',files);
    layer.msg('正在上传，请稍后');
    $.ajax({
        //请求方式
        type : "POST",
        //请求地址
        url : "ajax_upload",
        data : formData,
        cache:false,  //默认是true，但是一般不做缓存
        processData:false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
        contentType:false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
        //请求成功
        success : function(result) {
            if(result.err==0){
                layer.msg(result.msg);
                $('#cardImgF').val(result.data);
            }else{
                $('#cardImgF').val('');
                alert('文件信息错误,请重新上传');return false;
            }



        },
        //请求失败，包含具体的错误信息
        error : function(e){
            console.log(e.status);
            console.log(e.responseText);
        }
    });

});
$(document).on('change','#upload_img3',function() {
    var files = document.getElementById('upload_img3').files[0];
    var formData = new FormData();
    formData.append('file',files);
    layer.msg('正在上传，请稍后');
    $.ajax({
        //请求方式
        type : "POST",
        //请求地址
        url : "ajax_upload",
        data : formData,
        cache:false,  //默认是true，但是一般不做缓存
        processData:false, //用于对data参数进行序列化处理，这里必须false；如果是true，就会将FormData转换为String类型
        contentType:false,  //一些文件上传http协议的关系，自行百度，如果上传的有文件，那么只能设置为false
        //请求成功
        success : function(result) {
            if(result.err==0){
                layer.msg(result.msg);
                $('#cardImgS').val(result.data);
            }else{
                $('#cardImgS').val('');
                alert('文件信息错误,请重新上传');return false;
            }



        },
        //请求失败，包含具体的错误信息
        error : function(e){
            console.log(e.status);
            console.log(e.responseText);
        }
    });

});
</script>